import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/pages/home/home_controller.dart';
import 'package:flutter_changdian_football/pages/home/widget/banner_widget.dart';
import 'package:flutter_changdian_football/pages/home/widget/header_widget.dart';
import 'package:flutter_changdian_football/pages/home/widget/new_widget.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/get_state_manager/get_state_manager.dart';

// 首页
class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
  
  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);

    return Scaffold(
      backgroundColor: const Color(0xffF8FAF9),
      body: GetBuilder<HomeController>(
        builder: (homeController) {
          return Column(
            children: [
              const AddressAndMsgWidget(),

              Expanded(
                child: ExtendedNestedScrollView(
                  physics: const BouncingScrollPhysics(),
                  headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
                    return const [
                      BannerAndRibbonWidget(),
                    ];
                  }, 
                  pinnedHeaderSliverHeightBuilder: () {
                    return kToolbarHeight - 60.w;
                  },
                  onlyOneScrollInBody: true,
                  body: SizedBox(
                    width: double.infinity,
                    height: double.infinity,
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: const [
                        Expanded(
                          child: NewWidget(),
                        ),
                      ],
                    ),
                  ),
                ),
              )
            ],
          );
        }
      ),
    );
  }

}